package org.springboot.demo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
public class SimpleController {

	@Autowired
	JdbcTemplate jdbcTemplate;

	@RequestMapping("/")
	@ResponseBody
	List<Customer> home() {
		return  jdbcTemplate
				.query("SELECT id, first_name, last_name FROM customers WHERE first_name = ?",
						new Object[] { "Josh" },
						(rs, rowNum) -> {
							return new Customer(rs.getLong("id"), rs
								.getString("first_name"), rs
								.getString("last_name"));
						});
	}

	@RequestMapping("/hello")
	@ResponseBody
	String hello() {
		System.out.println("bbb");
		return "hello every body";
	}

}